/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.dem;

import java.util.LinkedList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author morfant
 */
public class EventsTableModel extends AbstractTableModel {

    private LinkedList<Event> listOfEvent;
    private String[] columnName = {"t старта", "t системы", "t условное", "Тип"};

    public EventsTableModel(LinkedList<Event> listOfEvent) {
        this.listOfEvent = listOfEvent;
    }

    public LinkedList<Event> getListOfEvent() {
        return listOfEvent;
    }

    public void setListOfEvent(LinkedList<Event> listOfEvent) {
        this.listOfEvent = listOfEvent;
    }

    @Override
    public int getRowCount() {
        return listOfEvent.size();
    }

    @Override
    public int getColumnCount() {
        return columnName.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Event temp = listOfEvent.get(rowIndex);

        switch (columnIndex) {
            case 0: {
                return (new Integer(temp.getStartTime()));
            }
            case 1: {
                return (new Integer(temp.getAppearanceTime()));
            }
            case 2: {
                return (new Integer(temp.getRelativeTime()));
            }
            case 3: {
                return temp.getEventType();
            }
            default: {
                throw new IndexOutOfBoundsException("Такой колонки не существует!");
            }
        }
    }

    @Override
    public String getColumnName(int column) {
        return columnName[column];
    }
}
